package com.webchat.search;

import com.webchat.common.util.SpringContextUtil;
import com.webchat.rmi.annotation.EnableRpcPermissionFilter;
import com.webchat.rmi.annotation.EnableRpcPermissionInterceptor;
import com.webchat.search.messagequeue.consumer.ArticleSyncRedisQueueConsumer;
import com.webchat.search.service.voctor.ArticleMilvusService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@EnableDiscoveryClient
@ComponentScan("com.webchat")
@EnableFeignClients("com.webchat.rmi")
@EnableRpcPermissionInterceptor
@EnableRpcPermissionFilter
public class WebchatSearchApplication {

    public static void main(String[] args) {
        SpringApplication.run(WebchatSearchApplication.class, args);

        /**
         * 服务启动成功后开启队列消费(文章数据同步Milvus)
         */
        SpringContextUtil.getBean(ArticleSyncRedisQueueConsumer.class).initBean();

        new Thread(() -> SpringContextUtil.getBean(ArticleMilvusService.class).consumeTask()).run();;
    }
}
